Smart Buttons
Controls/XML Elements

JavaScript Snippets <JsSnippet>

This control consumes JavaScript snippets inside of a Smart Buttons script.

Configuring

You can configure JsSnippet by entering the JavaScript in the JavaScript Snippet XML Generator.

To configure with the JavaScript Snippet XML Generator:
  1. Open the Smart Buttons Editor to create a script.

  2. Click JavaScript snippet <JsSnippet> to display the JavaScript Snippet XML Generator.

  3. Enter the Variable name.

  4. Optional. In Optional script URLs, enter the URL to load a JavaScript script and click the Plus icon.

    Tip! You can also add a URL using the ScriptsUrls element.

  5. Enter the JavaScript code.

    Click Test snippet to perform the function.

  6. Click Submit.

Executing

All variables from the script are available in JavaScript execution context. <JsSnippet> returns the text/string value back to the Smart Buttons script (into provided 'VarName'), which can then be consumed by other XML elements in Smart Buttons.

For example, the JavaScript snippet Var: TextToDisplay is returned and the value is displayed in the ShowMessage XML element.

Multiple Variables

It is also possible to return multiple variables back into XML executable context in the form of a JSON object (JSON property => 'VarName', JSON property value => 'VarName' value ).

For example:

Copy
<ButtonConf ButtonName="Return multiple vars" Description="" QuickCommand="">
<JsSnippet VarName="">
<Code><![CDATA[
return {
Costcenter: '128739',
CustomerNumber: 87979
};
]]></Code>
</JsSnippet>
<ShowMessage>[Costcenter], [CustomerNumber]</ShowMessage>
</ButtonConf>